package com.xsq.provider.dubboprovider.serviceimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.xsq.api.service.TestService;

import java.util.Random;

/**
 * @ClassName TestServiceImpl
 * @Description TODO
 * @Author xsq
 * @Date 2020/6/24 14:20
 **/
@Service
public class TestServiceImpl implements TestService {

    final Random random = new Random();

    @Override
    public String order() {
        randomSleep();
        return "下单";
    }

    @Override
    public String pay() {
        randomSleep();
        return "支付";
    }

    @Override
    public String shipments() {
        randomSleep();
        return "发货";
    }

    /**
     * 休眠0到100毫秒
     */
    private void randomSleep() {
        try {
            Thread.sleep(random.nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
